﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LoLEdit
{
    public class RowControls : IDisposable
    {
        #region Private Members

        private TextBox m_txtKey;
        private TextBox m_txtKeyName;
        private TextBox m_txtValueA;
        private TextBox m_txtValueB;
        private TextBox m_txtValueC;
        private TextBox m_txtValueD;
        private PictureBox m_picPreview;
        private Button m_btnColor;

        #endregion Private Members

        #region Public Properties

        public int RowIndex { get; set; }

        public UInt32 Key 
        {
            get
            {
                return UInt32.Parse(m_txtKey.Text);
            }
            set
            {
                m_txtKey.Text = "" + value;
            }
        }

        public String KeyName 
        {
            get
            {
                return m_txtKeyName.Text;
            }
            set
            {
                m_txtKeyName.Text = value;
            }
        }

        public String ValueA
        {
            get
            {
                return m_txtValueA.Text;
            }
            set
            {
                m_txtValueA.Text = value;
            }
        }

        public String ValueB
        {
            get
            {
                return m_txtValueB.Text;
            }
            set
            {
                m_txtValueB.Text = value;
            }
        }

        public String ValueC
        {
            get
            {
                return m_txtValueC.Text;
            }
            set
            {
                m_txtValueC.Text = value;
            }
        }

        public String ValueD
        {
            get
            {
                return m_txtValueD.Text;
            }
            set
            {
                m_txtValueD.Text = value;
            }
        }


        public TextBox txtKey
        {
            get
            {
                return m_txtKey;
            }
        }

        public TextBox txtKeyName
        {
            get
            {
                return m_txtKeyName;
            }
        }

        public TextBox txtValueA
        {
            get
            {
                return m_txtValueA;
            }
        }

        public TextBox txtValueB
        {
            get
            {
                return m_txtValueB;
            }
        }

        public TextBox txtValueC
        {
            get
            {
                return m_txtValueC;
            }
        }

        public TextBox txtValueD
        {
            get
            {
                return m_txtValueD;
            }
        }

        public PictureBox picPreview
        {
            get
            {
                return m_picPreview;
            }
        }

        public Button btnColor
        {
            get
            {
                return m_btnColor;
            }
        }

        #endregion Public Properties

        #region Public Methods

        /// <summary>
        /// Creates and initializes the controls that represent a row in a segment panel
        /// </summary>
        public RowControls()
        {
            m_txtKey = new TextBox();
            m_txtKeyName = new TextBox();
            m_txtValueA = new TextBox();
            m_txtValueB = new TextBox();
            m_txtValueC = new TextBox();
            m_txtValueD = new TextBox();
            m_picPreview = new PictureBox();
            m_btnColor = new Button();

            m_txtKey.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            m_txtKey.Dock = System.Windows.Forms.DockStyle.Fill;
            m_txtKey.Name = "txtKey";
            m_txtKey.ReadOnly = true;
            m_txtKey.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;

            m_txtKeyName.Dock = System.Windows.Forms.DockStyle.Fill;
            m_txtKeyName.Name = "txtKeyName";
            m_txtKeyName.ReadOnly = true;
            
            m_txtValueA.Dock = System.Windows.Forms.DockStyle.Fill;
            m_txtValueA.Name = "txtValueA";
            
            m_txtValueB.Dock = System.Windows.Forms.DockStyle.Fill;
            m_txtValueB.Name = "txtValueB";
            
            m_txtValueC.Dock = System.Windows.Forms.DockStyle.Fill;
            m_txtValueC.Name = "txtValueC";
            
            m_txtValueD.Dock = System.Windows.Forms.DockStyle.Fill;
            m_txtValueD.Name = "txtValueD";
            
            m_picPreview.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            m_picPreview.Dock = System.Windows.Forms.DockStyle.Fill;
            m_picPreview.Name = "picPreview";
            m_picPreview.TabStop = false;

            m_btnColor.Dock = System.Windows.Forms.DockStyle.None;
            m_btnColor.Image = global::LoLEdit.Properties.Resources.ChooseColor;
            m_btnColor.Name = "btnColor";
            m_btnColor.Size = new System.Drawing.Size(30, 30);
            m_btnColor.UseVisualStyleBackColor = true;
        } //end RowControls constructor

        /// <summary>
        /// Disposes of the RowControls class members
        /// </summary>
        public void Dispose()
        {
            m_txtKey.Dispose();
            m_txtKeyName.Dispose();
            m_txtValueA.Dispose();
            m_txtValueB.Dispose();
            m_txtValueC.Dispose();
            m_txtValueD.Dispose();
            m_picPreview.Dispose();
            m_btnColor.Dispose();
        } //end Dispose

        #endregion Public Methods

    } //end RowControls
} //end LolEdit
